# [Choosing the Shell](https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html)
SHELL := /bin/bash

# Specify the `--no-print-directory` inside the Makefile itself
ifndef VERBOSE
	MAKEFLAGS += --no-print-directory
endif

# Read IoT version from the latest git tags
VERSION?=$(shell git describe --tags `git rev-list --tags --max-count=1`)

# Read latest commit hash
COMMIT?=$(shell git rev-parse HEAD)

.PHONY: test
test:
	go test -race -timeout 60s ./...

.PHONY: build-linux
build-linux:
	CGO_ENABLED=1 go build \
		-o target/bin/server \
		-gcflags="-trimpath=$(PWD)" \
		cmd/main.go

.PHONY: build-windows
build-windows:
	CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build \
		-o target/bin/server.exe \
		-gcflags="-trimpath=$(PWD)" \
		cmd/main.go
